From: Jan Beulich Date: Thu, 15 Dec 2016 10:13:32 +0000 (+0100) Subject: x86emul: ignore most segment bases for 64-bit mode in is_aligned() X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3128 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=6e616a3cef4d782253787904bf3d641112eafa14;p=xen.git x86emul: ignore most segment bases for 64-bit mode in is_aligned() ops->read_segment() will report whatever is actually there in the register, so we need to actively distinguish ES/CS/SS/DS from FS/GS. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index 05fa342a94..dfdcd6ce7b 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1642,12 +1642,17 @@ static bool is_aligned(enum x86_segment seg, unsigned long offs, /* Expecting powers of two only. */ ASSERT(!(size & (size - 1))); - /* No alignment checking when we have no way to read segment data. */ - if ( !ops->read_segment ) - return true; + if ( mode_64bit() && seg < x86_seg_fs ) + memset(®, 0, sizeof(reg)); + else + { + /* No alignment checking when we have no way to read segment data. */ + if ( !ops->read_segment ) + return true; - if ( ops->read_segment(seg, ®, ctxt) != X86EMUL_OKAY ) - return false; + if ( ops->read_segment(seg, ®, ctxt) != X86EMUL_OKAY ) + return false; + } return !((reg.base + offs) & (size - 1)); }